package top.pmwly.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.w3c.dom.DocumentType;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author Herther
 * @version 1.0.0
 * @ClassName Swagger2Config.java
 * @Description Swagger2配置类
 * @createTime 2021年09月21日 12:37:00
 */
@Configuration
@EnableSwagger2
@EnableKnife4j
public class Swagger2Config {


    @Bean
    public Docket docketA(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("后台管理系统")
                .select()
                .apis(RequestHandlerSelectors.basePackage("top.pmwly.web"))
                .build();
    }
    @Bean
    public Docket docketB(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("前台商城")
                .select()
                .apis(RequestHandlerSelectors.basePackage("top.pmwly.mobile"))
                .build();
    }



    /**
     * 配置Swagger信息 apiinfo
     * @return
     */
    private ApiInfo apiInfo(){
        //配置作者信息
        Contact DEFAULT_CONTACT = new Contact("Herther", "https://www.pmwly.top", "34675628@qq.com");
        return  new ApiInfo(
                "胖虎外卖",
                "胖虎外卖在线文档",
                "v1.0",
                "https://www.pmwly.top",
                DEFAULT_CONTACT,
                "Apache 2.0",
                "https://www.pmwly.top",
                new ArrayList());
    }

}
